package com.example.monthdateselector;

import hirondelle.date4j.DateTime;

public class Range{
	private DateTime start;
	private DateTime end;
	
	
	public Range(DateTime start, DateTime end) {
		this.start = start;
		this.end=end;
	}
	
	public Range(DateTime start, int lenght) {
		this.start=start;
		this.end=start.plusDays(lenght);
	}

	public boolean isInRange(DateTime testDate){
		if(start==null||testDate==null||end==null){
			return false;
		}
		return testDate.gt(start)&&testDate.lt(end);
	}
	
	public int getLength(){
		if(start==null||end==null){
			return 0;
		}else{
			return start.numDaysFrom(end);
		}
	}
	
	public DateTime getStart() {
		return start;
	}

	public void setStart(DateTime start) {
		this.start = start;
	}

	public DateTime getEnd() {
		return end;
	}

	public void setEnd(DateTime end) {
		this.end = end;
	}

	@Override
	public String toString() {
		return "Range [起始:" + start + ", 结束:" + end + "]";
	}

}
